package com.example.demomybatismapper.user;

import com.example.demomybatismapper.generator.mapper.UserMapper;
import com.example.demomybatismapper.generator.model.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserController {
    @Resource
    UserMapper userMapper;

    @PostMapping("/save")
    public void save(@RequestBody User user) {
        userMapper.insertSelective(user);
    }

    @GetMapping("/list")
    public List<User> list() {
        return userMapper.selectAll();
    }
}
